package com.youth.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.youth.entity.po.Commodity;
import com.youth.entity.vo.CommodityVO;

import java.lang.reflect.InvocationTargetException;
import java.util.Date;
import java.util.UUID;

/**
 * @ClassName OrderCodeUtils
 * @Description: TODO 通用工具类
 * @Author yjwu
 * @Date 2019/10/30 21:41
 **/
public class CommonUtil {

    /**
     * @MethodName: voToPo
     * @Description: TODO 商品vo转换为po
     * @Param: * @param commodityVO
     * @Return: {@link Commodity}
     * @Author: yjwu
     * @Date: 2019/11/17 12:26
     **/
    public static Commodity commodityVoToPo(CommodityVO commodityVO) {
        Commodity commodity = new Commodity();
        commodity.setCode(CodeUtil.getUUIDCode());
        commodity.setName(commodityVO.getName());
        commodity.setTypeThreeId(commodityVO.getTypeThreeId());
        commodity.setHeadline(commodityVO.getHeadline());
        commodity.setPlaceAreaId(commodityVO.getPlaceAreaId());
        commodity.setDoHot(commodityVO.getDoHot());
        commodity.setKeywords(commodityVO.getKeywords());
        commodity.setPrice(commodityVO.getPrice());
        commodity.setStorageNumber(commodityVO.getStorageNumber());
        commodity.setSoldNumber(commodityVO.getSoldNumber());
        commodity.setDescription(commodityVO.getDescription());
        commodity.setRemark(commodityVO.getRemark());
        commodity.setUpdateTime(new Date());
        commodity.setCreateTime(new Date());

        return commodity;
    }

    /**
     * @MethodName: poToVo
     * @Description: TODO 商品po转vo
     * @Param: * @param commodityVO
     * @Return: {@link Commodity}
     * @Author: yjwu
     * @Date: 2020/1/6 9:50
     **/
    public static CommodityVO commodityPoToVo(Commodity commodity) {
        CommodityVO commodityVO = new CommodityVO();
        commodityVO.setCode(commodity.getCode());
        commodityVO.setName(commodity.getName());
        commodityVO.setTypeThreeId(commodity.getTypeThreeId());
        commodityVO.setHeadline(commodity.getHeadline());
        commodityVO.setPlaceAreaId(commodity.getPlaceAreaId());
        commodityVO.setDoHot(commodity.getDoHot());
        commodityVO.setKeywords(commodity.getKeywords());
        commodityVO.setPrice(commodity.getPrice());
        commodityVO.setStorageNumber(commodity.getStorageNumber());
        commodityVO.setSoldNumber(commodity.getSoldNumber());
        commodityVO.setDescription(commodity.getDescription());
        commodityVO.setRemark(commodity.getRemark());

        return commodityVO;
    }
}
